import Vue from "vue";
import VueRouter from "vue-router";
import config from "@/configs/config.js";
// import store from "./store";
import codeFormat from "@/template/codeFormat";
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "home",
    component: () => import("./views/home"),
  },
  {
    path: "/cropper",
    name: "cropper",
    component: () => import("./views/cropper.vue"),
  },
  {
    path: "*",
    hidden: true,
    name: "errorPage404",
    meta: {},
    component: () => import("_c/message.vue"),
  },
];

const router = new VueRouter({
  routes,
  base: config.ctxPath,
});
router.beforeEach((to, from, next) => {
  // let token = store.getters.token;
  // if (token) {
  //   let title = to.meta?.title;
  //   if (title) document.title = title;
  next();
  // } else {
  //   if (to.name == "home") {
  //     next();
  //   } else {
  //     next({ name: "home" });
  //   }
  // }
});

//加载的http拦截器
codeFormat({
  router,
});
export default router;
